﻿$(function () {
    //Lay checkbox co ID=checkAll
    var $checkBox = $("input:checkbox[id$=chkAll]");
    //Lay mang cac checkbox co name =cid
    var $tblChkBox = $("input:checkbox[name$=Id]");
    //Them su kien click cho chkAll
    $checkBox.click(function () {
        $tblChkBox
                .attr('checked', $checkBox
                .is(':checked'));
    }
    );

    //Them su kien cho cac checkbox co name la =cid
    //Khi bo check thi chkAll cung tro ve trang thai Uncheck
    $tblChkBox.click(
        function (e) {
            if (!$(this)[0].checked) {
                $checkBox.attr("checked", false);
            }
        }
    );


    //Hien thong bao nhac nho nguoi dung co that su muon xoa cac muc da chon
    $("input.multidelete").click(function () {
        var n = $("input:checkbox[name$=Id]:checked").length;
        if (n == 0) {
            alert("Please choose at leats one item to delete !");
            return false;
        }
        else {
            return confirm("WARNING: The select items will be romoved permanently. Are you sure ?");
        }
    });
});